
package com.be.beadmin.device.repository;

import com.be.beadmin.device.entity.ToolInfo;
import com.be.beadmin.device.entity.SpareInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
* @author sly
* @date 2023-08-26
**/
public interface ToolInfoRepository extends JpaRepository<ToolInfo, String>, JpaSpecificationExecutor<ToolInfo> {

    ToolInfo findToolInfoByIdAndDelete(String id, Integer delete);

    ToolInfo findToolInfoById(String id);

    ToolInfo findToolInfoByTakeawayDateAndDelete(Date takeawayDate, Integer delete);

    ToolInfo findToolInfoByScrappedDateAndDelete(Date scrappedDate, Integer delete);

    ToolInfo findToolInfoByContractDateAndDelete(Date contractDate, Integer delete);

    ToolInfo findToolInfoByToolIdAndDelete(String toolId , Integer delete);

    @Query(value = "select sdt.id from sys_dict_type sdt where sdt.dict_name = ?1 and sdt.is_delete = 0", nativeQuery = true)
    String findDictTypeId(String dictName);

    @Query(value = "select sdd.key_name from sys_dict_data sdd where sdd.dict_type_id = ?1 and sdd.is_delete = 0", nativeQuery = true)
    List<String> findKeyNameByDictTypeId(String DictTypeId);
}